
package com.zzvcom.sms.entity;

import com.zzvcom.sms.exception.AppParamException;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

public abstract class AppMopedParam extends AppParam {
    private final String licensePlateNumber;
    private final String rfidPlateNumber;
    private final String vin;

    protected AppMopedParam(String appKey, String companyCode, String licensePlateNumber, String rfidPlateNumber, String vin, Long timestamp, String nonce) {
        super(appKey, companyCode, timestamp, nonce);
        if (StringUtils.isBlank(licensePlateNumber)) {
            throw new AppParamException("备案车牌号参数不存在");
        } else if (StringUtils.isBlank(rfidPlateNumber)) {
            throw new AppParamException("电子车牌号参数不存在");
        } else if (StringUtils.isBlank(vin)) {
            throw new AppParamException("车架号参数不存在");
        } else {
            this.licensePlateNumber = licensePlateNumber;
            this.rfidPlateNumber = rfidPlateNumber;
            this.vin = vin;
        }
    }

    @Override
    public Map<String, String> toMap() {
        Map<String, String> treeMap = super.toMap();
        treeMap.put("licensePlateNumber", this.licensePlateNumber);
        treeMap.put("rfidPlateNumber", this.rfidPlateNumber);
        treeMap.put("vin", this.vin);
        return treeMap;
    }
}
